package com.smart.vo;

import lombok.Data;
import java.util.List;
import java.io.Serializable;
import com.smart.entity.SysDept;
import com.smart.entity.SysMenu;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * @author lgb
 * @date 2020年6月15日 上午9:24:46
 * Copyright (C) 深圳工勘科技
 * @说明: TreeSelect
 **/
@Data
public class TreeSelect implements Serializable{

	private static final long serialVersionUID = 727782240920937509L;
	/** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect() {}
    
    public TreeSelect(SysDept dept) {
        this.id = dept.getId();
        this.label = dept.getName();
        this.children = dept.getChildren() == null ? null : 
        	dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
    
    public TreeSelect(SysMenu menu) {
        this.id = menu.getId();
        this.label = menu.getName();
        this.children = menu.getChildren() == null ? null :
        	menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
    
}